
import axios from 'axios';
//用来存储考试信息相关数据及操作
const state = {
    exammessage: [],//存储从服务器得到的考试信息
    hisexammsg:[]
};
const actions = {
    getexamMsg({ commit }) {//发送请求 -----后期封装到axios二次封装中
        var data1;
        axios.get(`http://42.193.219.14:8080/getExamInformation`,{
            headers: {
                "Content-Type": "application/json",
                "Authorization": "Bearer " + sessionStorage.getItem('token')
              },
        }).then(
            response => {
                data1 = response.data.data;
                console.log(data1)
                commit('getexamMsg', data1);//成功了提交
            },
            error => {
                console.log('请求失败', error.message);
            }
        )
    },
    getHistyexam({ commit }) {//发送请求 -----后期封装到axios二次封装中
        var data1;
        axios.get(`http://42.193.219.14:8080/getHistoryExamByTeacher`, {
            headers: {
                "Content-Type": "application/json",
                "Authorization": "Bearer " + sessionStorage.getItem('token')
              },
        }).then(
            response => {
                data1 = response.data.data;
                console.log(data1)
                commit('getHistyexam', data1);//成功了提交
            },
            error => {
                console.log('请求失败', error.message);
            }
        )
    }
};
const mutations = {
    getexamMsg(state,data) {
        state.exammessage = data;
    },
    getHistyexam(state,data) {
        state.hisexammsg = data;
    }
};
const getters = {};
export default {
    state,
    actions,
    mutations,
    getters
}